//
//  WHRDiscountCouponCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/12/3.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "WHRDiscountCouponCell.h"
#import "UIImageView+WebCache.h"


@implementation WHRDiscountCouponCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self creatView];
        
    }
    return self;
}

- (void)creatView {
    
    self.discountImg = [[UIImageView alloc]init];
    [self.contentView addSubview:self.discountImg];
    
    self.titleLabel = [[UILabel alloc]init];
    self.titleLabel.textColor = COLOR_DIV;
    self.titleLabel.font = FONT_FOURTEEN;
    [self.contentView addSubview:self.titleLabel];
    
    self.fullLabel = [[UILabel alloc]init];
    self.fullLabel.textColor = COLOR_Gray;
    self.fullLabel.font = [UIFont systemFontOfSize:10];
    [self.contentView addSubview:self.fullLabel];
    
    
    self.timeLabel = [[UILabel alloc]init];
    self.timeLabel.textColor = COLOR_Gray;
    self.timeLabel.font = [UIFont systemFontOfSize:10];
    [self.contentView addSubview:self.timeLabel];
    
    
    self.getBtn = [[UIButton alloc]init];
    [self.getBtn setTitle:@"立即使用" forState:UIControlStateNormal];
    self.getBtn.backgroundColor = COLOR_ORG;
    [self.getBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.getBtn.titleLabel.font = [UIFont systemFontOfSize:10];
    [self.contentView addSubview:self.getBtn];
    
    
    
    
}

- (void)setlayout {
    
    self.discountImg.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 10)
    .widthIs(100)
    .heightIs(80);
    
    self.titleLabel.sd_layout
    .leftSpaceToView(self.discountImg, 10)
    .topSpaceToView(self.contentView, 10)
    .widthIs(100)
    .heightIs(20);
    
    self.fullLabel.sd_layout
    .leftEqualToView(self.titleLabel)
    .topSpaceToView(self.titleLabel, 10)
    .widthIs(100)
    .heightIs(20);
    
    self.timeLabel.sd_layout
    .leftSpaceToView(self.discountImg, 10)
    .topSpaceToView(self.fullLabel, 10)
    .rightSpaceToView(self.contentView, 10);
    
    
    self.getBtn.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .centerYEqualToView(self.discountImg)
    .widthIs(80)
    .heightIs(20);
    
    [self setupAutoHeightWithBottomView:self.discountImg bottomMargin:10];
    
    
}

- (void)setModel:(WHRDiscountCouponModel *)model {
    
    _model = model;
     [_discountImg sd_setImageWithURL:[NSURL URLWithString:_model.couponImage] placeholderImage:[UIImage imageNamed:@"placeHold"]];
    _titleLabel.text  = _model.couponName;
    _fullLabel.text = [NSString stringWithFormat:@"满%@可用",_model.faceValue];
    _timeLabel.text = [NSString stringWithFormat:@"有效期:%@-%@",_model.effectiveDatetime,_model.expireDatetime];
     [self setlayout];
    
}





@end
